using System.Collections.Generic;
using IntelFront.Models;

namespace IntelFront.Migrations
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    internal sealed class Configuration : DbMigrationsConfiguration<IntelFront.Models.TheContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
        }

        protected override void Seed(IntelFront.Models.TheContext context)
        {
            base.Seed(context);
            var Admins = new List<Admin>
            {
                new Admin {Account = "oureda",Avator = "www.baidu.com",Name = "oureda",Pwd="oureda",Type = 1}
            };

            foreach (var admin in Admins)
            {
                context.Admins.Add(admin);
            }
            context.SaveChanges();
            var Users = new List<User>
            {
            };
            for (int i = 0; i < 10; i++)
            {
                Users.Add(new User
                {
                    Account = "user" + i,
                    Name = "user" + i,
                    Avator = "www.baidu.com",
                    Pwd = "123456"
                });
            }
            foreach (var user in Users)
            {
                context.Users.Add(user);
            }
            context.SaveChanges();
            var Records = new List<Record>();
            for (int i = 0; i < 10; i++)
            {
                Records.Add(new Record
                {
                    Ip = "localhost",
                    UserId = Users[i].Id
                });
            }
            foreach (var record in Records)
            {
                context.Records.Add(record);
            }
            context.SaveChanges();
        }
    }
}
